class userMedia
{
    constructor() {
        if ('mediaDevices' in navigator && 'getUserMedia' in navigator.mediaDevices) {
            console.log("Let's get this party started")

        } else {
            throw new Error('this navigator does not support audio or video function');
        }
    }

    /**
     * 授权使用媒体
     * @param constraints {audio: true,video: {width: { min: 1280 },height: { min: 720 }}}
     */
    getPermission(constraints)
    {
        var constraints = {"video": false, "audio":true};
        navigator.mediaDevices.getUserMedia(constraints)
        .then(function(stream) {
          /* 使用这个stream stream */
        })
        .catch(function(err) {
          throw new Error('video stream or audio stream not fund!');
        });
    }
}